package io.renren.modules.shop.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.renren.common.utils.R;
import io.renren.modules.shop.model.ShopManage;
import io.renren.modules.shop.service.ShopManageService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author A夜兔A
 * @data 2021年11月16日 13:12
 */
@RestController
@RequestMapping("/shopmanage")
public class ShopManageController {

    @Autowired
    private ShopManageService shopManageService;

    @ApiOperation("查询店铺列表")
    @GetMapping("/getShopList")
    public R getShopList(@RequestParam(value = "pageNum",defaultValue = "1")Integer pageNum,
                         @RequestParam(value = "pageSize",defaultValue = "10")Integer pageSize){


        return shopManageService.getShopList(pageNum,pageSize);
    }

    @ApiOperation("新增店铺")
    @PostMapping("/addShop")
    public R addShop(@RequestBody ShopManage shopManage){

        return shopManageService.addShop(shopManage);

    }

    @ApiOperation("更新店铺")
    @PostMapping("/updateShop")
    public R updateShop(@RequestBody ShopManage shopManage){
        boolean b = shopManageService.updateById(shopManage);
        if (b){
            return R.ok("操作成功");
        }else {
            return R.error(500,"更新失败");
        }

    }

    @ApiOperation("删除店铺")
    @GetMapping("/delShop")
    public R delShop(Integer shopId){
        return shopManageService.delShop(shopId);
    }


    @ApiOperation("获得店铺信息")
    @GetMapping("/getShopMessage")
    public R getShopMessage(){
        return shopManageService.getShopMessage();
    }

}
